var gulp = require('gulp'),
    minifycss = require('gulp-minify-css'),//css合并
    concat = require('gulp-concat'),//文件合并
    rename = require('gulp-rename'),//文件更名
    notify = require('gulp-notify'),//提示信息
    autoprefixer = require('gulp-autoprefixer'),
    less = require("gulp-less"),
    uglify = require('gulp-uglify');//增加后缀


//压缩重命名css
gulp.task('css', function() {
  return gulp.src('./src/*.css')
    .pipe(autoprefixer({
        browsers: ['last 5 versions','Android >= 4.0']
    }))
    .pipe(minifycss())
    .pipe(rename({ suffix: '.min' }))
    .pipe(gulp.dest('./dist'))
    .pipe(notify({ message: 'css task ok' }));
});
//转化less
gulp.task('less', function () {
    gulp.src('./src/*.less')
    .pipe(less())
    .pipe(autoprefixer({
        browsers: ['last 5 versions','Android >= 4.0']
    }))
    .pipe(minifycss())
    .pipe(rename({ suffix: '.min' }))
    .pipe(gulp.dest('./dist'));
});
//压缩重命名js
gulp.task('js',function(){
    return gulp.src('./src/*.js')
    .pipe(uglify())
    .pipe(rename({ suffix: '.min' }))
    .pipe(gulp.dest('./dist'))
    .pipe(notify({message: 'js task ok'}))
})

gulp.task('watch', function () {
    gulp.watch(['./src/*.less','./src/*.js'], ['less','js']);
});
